package com.gm.camunda.config;


import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;

import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;

/**
 * {@code @Author}: zhang liang
 * {@code @Date}: 2022/10/1 13:34
 * {@code @BelongsProject}: gm
 * {@code @BelongsPackage}: com.gmadmin.configuration.datasource
 * {@code @Description}: camunda数据源配置
 */
public class CamundaDataSourceConfig {

    @Bean(name="camundaBpmDataSource")
    @ConfigurationProperties(prefix="spring.datasource.camunda")
    public DataSource secondaryDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name="camundaBpmTransactionManager")
    public PlatformTransactionManager camundaTransactionManager(@Qualifier("camundaBpmDataSource") DataSource dataSource) {
        return new DataSourceTransactionManager(dataSource);
    }

}
